<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\RedisController;
use App\Models\WebConfig;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use Illuminate\Support\Facades\Request;
use Redis;

class WebConfigController extends AdminController
{
    protected $title = '系统参数';

    protected function grid()
    {
        $grid = new Grid(new WebConfig());
        $grid->column('id', 'Id号');
        $grid->column('sign', '标签');
        $grid->column('keyname', '配置名称');
        $grid->column('keyvalue', '配置值');
        $grid->column('sort', '排序');

        $grid->model()->orderBy('sort', 'asc');


        return $grid;
    }

    protected function detail($id)
    {
        $show = new Show(WebConfig::findOrFail($id));

        $show->field('id', __('Id号'));
        $show->field('sign', __('标签'));
        $show->field('keyname', __('配置名称'));
        $show->field('keyvalue', __('配置值'));
        $show->field('sort', '排序');

        return $show;
    }

    protected function form()
    {
        $form = new Form(new WebConfig());

        $form->text('id', 'Id号')->readonly();
        $form->text('sign', '标签')->required();
        $form->text('keyname', '配置名称')->required();
        $form->text('keyvalue', '配置值')->required();
        $form->text('sort', '排序');

        return $form;
    }
}